package cn.xuewenbao.edu.controller;


import cn.xuewenbao.edu.entity.vo.JournalDetailVo;
import cn.xuewenbao.edu.entity.vo.JournalIndexVo;
import cn.xuewenbao.edu.entity.vo.JournalPublishVo;
import cn.xuewenbao.edu.service.JournalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 期刊表 前端控制器
 * </p>
 *
 * @author mafayu
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/edu/journal")
@Slf4j
@Api(tags = "期刊表")
public class JournalController {

    @Autowired
    private JournalService journalService;

    @ApiOperation(value = "获取期刊专栏页的期刊列表")
    @GetMapping("getJournalColumnList")
    public Result<?> getJournalColumnList() {
        return journalService.getJournalColumnList();
    }

    //根据期刊内容id返回期刊内容详情
    @ApiOperation(value = "根据期刊内容id返回期刊内容详情")
    @GetMapping("getJournalDetail/{journalSubjectId}/{userId}")
    public Result<JournalDetailVo> getJournalDetail(@PathVariable String journalSubjectId, @PathVariable String userId){
        Result<JournalDetailVo> result = journalService.getJournalDetail(journalSubjectId, userId);
        return result;
    }

    //根据期刊id返回期刊列表
    @ApiOperation(value = "根据期刊id和期刊号, 返回对应期号的期刊首页")
    @GetMapping("getJournalIndexList/{journalId}/{number}")
    public Result<JournalIndexVo> getJournalIndexList(@PathVariable String journalId, @PathVariable String number){
        Result<JournalIndexVo> result=journalService.getJournalList(journalId, number);
        return result;
    }

    //根据期刊id返回期刊列表
    @ApiOperation(value = "根据期刊id, 返回最新一期的期刊首页")
    @GetMapping("getLatestJournalIndexList/{journalId}")
        public Result<JournalIndexVo> getLatestJournalIndexList(@PathVariable String journalId){
        Result<JournalIndexVo> result=journalService.getLatestJournalList(journalId);
        return result;
    }

    //添加新期刊内容
    @ApiOperation(value = "添加新期刊内容")
    @PostMapping ("addJournalSubject")
    public Result<?> addJournalSubject(@RequestBody JournalPublishVo vo){
       return journalService.addJournalSubject(vo);
    }

//    //根据id删除期刊
//    @ApiOperation(value = "根据id删除期刊")
//    @DeleteMapping("deleteJournal/{journalId}")
//    public Result<?> deleteJournal(@PathVariable String journalId) {
//        Result<?> result = journalService.deleteJournal(journalId);
//        return result;
//    }

}

